/*******************************************************
> Copyright (C) 2024 ==iot== All rights reserved.
> File Name: 15.c
> Author: wyf
> Created Time: 2024年09月07日 星期六 15时39分49秒
***************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ARRAY_SIZE 5
void handle_array(int *arr,int length);

int main(int argc, const char* argv[])
{

	//输入
	int arr[ARRAY_SIZE] = { 0 };
	int number = 0;
	int length = 0;
	int i = 0;
	for(i = 0;i < ARRAY_SIZE;i++)
	{
		printf("please input a integer : \n");
		scanf("%d",&number);
		arr[i] = number;
	}
	length = i;
	
	handle_array(arr,length);
	
	for(int j = 0; j < length;j++){
		printf("%d",arr[j]);
	}


    return 0;

}

void handle_array(int *arr,int length)
{
	//插入排序
	int key = 0;
	int j = 0;
	for(int i = 1;i < length;i++)
	{
		key = arr[i];
		for(j = i - 1;j >= 0; j--)
		{
			if(arr[j] > key)
			{
				arr[j+1] = arr[j];
			}
			else
			{
				break;
			}
		}
		arr[j+1] = key;
	}

	//找到数组最中间成员的值
	int middle_number = 0;
	middle_number = arr[(length/2)];
	
	//赋值
	for(int i = 0;i < (length / 2);i++)
	{
		arr[i] = middle_number;
	}
}
